<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>驾校查询</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;
      background-color: #f4f4f4;
    }
    .container {
      width: 80%;
      margin: 0 auto;
      padding: 20px;
      background-color: #fff;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }
    .header {
      text-align: center;
      margin-bottom: 20px;
    }
    .header h1 {
      margin: 0;
      padding: 10px 0;
    }
    .checkbox-group {
      display: flex;
      flex-wrap: wrap;
    }
    .checkbox-group label {
      margin: 5px;
    }
    .school-list {
      margin-top: 20px;
    }
    .school-item {
      border-bottom: 1px solid #ddd;
      padding: 10px 0;
    }
    .school-item:last-child {
      border-bottom: none;
    }
    .footer {
      text-align: center;
      margin-top: 20px;
      padding: 10px 0;
      background-color: #f8f8f8;
    }
    .footer button {
      margin: 0 10px;
    }
  </style>
</head>
<body>
<div class="container">
  <div class="header">
    <h1>驾校查询</h1>
  </div>
  <div class="checkbox-group">
    <select id="cityAreaSelect">
      <option id="xzid" value="0">请选择</option>
    </select>
  </div>
  <div class="school-list">
    <table>
      <thead>
      <tr>
        <th>驾校名称</th>
        <th>城区名称</th>
        <th>地址</th>
        <th>联系电话</th>
      </tr>
      </thead>
      <tbody>
      <tr th:each="per:${person.getList()}">
        <td th:text="${per.name}"></td>
        <td th:text="${per.cityAreaIdName}"></td>
        <td th:text="${per.address}"></td>
        <td th:text="${per.phone}"></td>
        <td><a th:href="driverschool/sel/${per.id}">修改</a></td>
      </tr>
      </tbody>
    </table>
  </div>
  <div class="footer">
    <a href="1">首页</a>
    <a th:if="${person.pageNum} != 1" th:href="${person.pageNum - 1}">上一页</a>
    <a th:if="${person.pageNum} != ${person.pages}" th:href="${person.pageNum + 1}">下一页</a>
    <a th:href="${person.pages}">末页</a>
  </div>
</div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>$(document).ready(function() {
  $.ajax({
    url: '/cityarea/city-areas',
    method: 'GET',
    success: function(data) {
      var select = $('#cityAreaSelect');
      data.forEach(function(area) {
        select.append('<option name="xzid" value="' + area.id + '">' + area.name + '</option>');
      });
    },
    error: function(error) {
      console.error('Error fetching city areas:', error);
    }
  });
});
</script>
</body>
</html>